﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BarberShop.BLL;
using BarberShop.Data;

public partial class BrandAdd : BasePage
{

    public int Id
    {
        get
        {
            return string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"]);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BandBrandInfo();
        }
    }

    protected void btn_add_Click(object sender, EventArgs e)
    {
        BrandInfo info = new BrandInfo();
        if (Id != 0)
        {
            info = BrandInfoBLL.GetBrandById(Id);
        }
        else
        {
            info.CreateDate = DateTime.Now;
        }
        info.BrandName = txt_brandName.Text.Trim();
        info.ModifyDate = DateTime.Now;
        bool r = BrandInfoBLL.SaveBrandInfo(info);
        if (r)
        {
            MsgBox("品牌保存成功！");
        }
        else { MsgBox("保存失败！"); }
    }
    #region 绑定品牌信息
    public void BandBrandInfo()
    {
        if (Id != 0)
        {
            var info = BrandInfoBLL.GetBrandById(Id);
            txt_brandName.Text = info.BrandName.Trim();
        }
    }
    #endregion
}
